package com.sky.controller.admin;

import com.sky.dto.DataOverViewQueryDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.OrdersRejectionDTO;
import com.sky.dto.OrdersStatisticsDTO;
import com.sky.result.Result;
import com.sky.service.OrderService;
import com.sky.vo.OrderReportVO;
import com.sky.vo.SalesTop10ReportVO;
import com.sky.vo.TurnoverReportVO;
import com.sky.vo.UserReportVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

/**
 * packageName com.sky.controller.admin
 *
 * @author fenglai
 * @version JDK 11
 * @className ReportController
 * @date 2023/12/6
 * @description TODO
 */
@RestController
@RequestMapping("/admin/report")
@Api(tags = "数据统计相关接口")
@Slf4j
public class ReportController {
    @Autowired
    private OrderService orderService;

    /**
     * @param dto: return Result<OrderReportVO>
     * @author fenglai
     * @date 2023/12/7 16:25
     * @description 订单统计功能
     */
    @ApiOperation("订单统计功能")
    @GetMapping("/ordersStatistics")
    public Result<OrderReportVO> countOrders(OrdersStatisticsDTO dto) {

        log.info("正在执行订单统计接口的功能...............开始日期:{},结束日期:{}", dto.getBegin(), dto.getEnd());

        OrderReportVO orderReportVO = orderService.countOrders(dto);

        return Result.success(orderReportVO);
    }

    /**
     * @param dto: return Result<UserReportVO>
     * @author fenglai
     * @date 2023/12/7 16:26
     * @description 用户统计功能
     */
    @ApiOperation("用户统计的功能")
    @GetMapping("/userStatistics")
    public Result<UserReportVO> userStatistics(OrdersStatisticsDTO dto) {

        log.info("正在执行用户统计的功能...........查询条件为:begin{},end{}", dto.getBegin(), dto.getEnd());

        UserReportVO userReportVO = orderService.userStatistics(dto);

        return Result.success(userReportVO);

    }

    /**
     * @param dto: 
     * return Result<TurnoverReportVO>
     * @author fenglai
     * @date 2023/12/7 17:06
     * @description 营业额统计功能
     */
    @ApiOperation("营业额统计功能")
    @GetMapping("/turnoverStatistics")
    public Result<TurnoverReportVO> turnoverStatistics(OrdersStatisticsDTO dto) {

        log.info("正在执行营业额统计功能.........。..查询条件为:begin{},end{}", dto.getBegin(), dto.getEnd());

        TurnoverReportVO turnoverReportVO = orderService.turnoverStatistics(dto);

        return Result.success(turnoverReportVO);

    }
    /**
     * @param dto:
     * return Result<SalesTop10ReportVO>
     * @author fenglai
     * @date 2023/12/7 18:10
     * @description 查询销量排名top10的功能
     */
    @ApiOperation("查询销量排名top10的功能")
    @GetMapping("/top10")
    public Result<SalesTop10ReportVO> top10(OrdersStatisticsDTO dto){

        log.info("正在执行查询销量排名top10的功能.........。..查询条件为:begin{},end{}", dto.getBegin(), dto.getEnd());

        SalesTop10ReportVO salesTop10ReportVO = orderService.getTop10(dto);

        return Result.success(salesTop10ReportVO);

    }
}